mHC optimization for expansion rate 4 (flag controlled)#3890
Open
dandragona wants to merge 1 commit into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
4 tasks
51c1161 to
1799cc1
Compare
fa7f997 to
b3a8bb4
Compare
shuningjin
reviewed
May 21, 2026
Collaborator
There was a problem hiding this comment.
Thanks for implementing mHC-lite! The core logic looks solid.
- Your implementation aligns with Eqs (2) and (3), and the parameter shapes are correct.
- Generalize k: The shortcut is currently hardcoded for k=4. While the
$k!$ permutation scaling limits large$k$ in practice, the underlying math applies to any$k$ . Let's parameterize it for flexibility. - Cleanup: I left a few minor inline comments. Please also revert unrelated formatting changes.
Also thanks for adding the unit tests! As a follow-up, you can run an end-to-end test to verify training stability and performance.
| [None, get_test_config_path()], | ||
| **extra_args, | ||
| run_name="test_mhc", | ||
| skip_jax_distributed_system=True, |
Collaborator
There was a problem hiding this comment.
do not skip, instead mark @pytest.mark.tpu_only for relavent tests
Collaborator
There was a problem hiding this comment.
remove skip_jax_distributed_system=True?
b3a8bb4 to
8e83338
Compare
8e83338 to
f8bcc1a
Compare
shuningjin
approved these changes
May 22, 2026
| [None, get_test_config_path()], | ||
| **extra_args, | ||
| run_name="test_mhc", | ||
| skip_jax_distributed_system=True, |
Collaborator
There was a problem hiding this comment.
remove skip_jax_distributed_system=True?
f8bcc1a to
944741b
Compare
parambole
reviewed
May 29, 2026
4eb4596 to
a4a169e
Compare
…tions and add enable_mhc_k4_shortcut feature gate
a4a169e to
2c88ab1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When expansion rate is equal to four we don't need to do sinkhorn as we can generate the doubly-stochastic matrix by taking a random convex combination of the permutation matrices (there are 4! = 24 of them when using expansion rate 4).
Based on https://arxiv.org/pdf/2601.05732.
Tests
Just tested with unit tests, adding the gemini-review now.
Waiting to performance test it once we get baseline DeepSeek v4 numbers.
Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.